﻿'========================================================================
'功能:員工資料商業邏輯物件
'作者:andy
'日期: 2011/1/31
'========================================================================

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Data.SqlClient
Imports System.Text
Imports System.Data
Namespace OAMS.BBL
    Public Class UsersBBL

        Public Function GetDeptByUID(ByVal UID As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetDeptByUID(UID)
        End Function


        ''' <summary>
        ''' 查出某一個人的基本資料
        ''' </summary>
        ''' <param name="login_id"></param>
        ''' <returns>查出某一個人的基本資料</returns>
        ''' <remarks>查出某一個人的基本資料</remarks>
        Public Function GetUser(ByVal login_id As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetUser(login_id)
        End Function
        ''' <summary>
        ''' 取得部門資料
        ''' </summary>
        ''' <param name="kind">0=正常,1=加一筆空白</param>
        ''' <returns>取得部門資料</returns>
        ''' <remarks>取得部門資料</remarks>
        Public Function GetDept(ByVal kind As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetDept(kind)
        End Function



        ''' <summary>
        ''' 檢查某一個工號是否在資料庫中
        ''' </summary>
        ''' <param name="UID"></param>
        ''' <returns>檢查某一個工號是否在資料庫中</returns>
        ''' <remarks>檢查某一個工號是否在資料庫中</remarks>
        Public Function UserIsExist(ByVal UID As String, ByVal dbName As String) As Boolean
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.UserIsExist(UID)
        End Function

        ''' <summary>
        ''' 查詢員工基本資料傳入工號或姓名都可以空白代表全部
        ''' </summary>
        ''' <param name="UIDOrUserName"></param>
        ''' <returns>查詢員工基本資料傳入工號或姓名都可以空白代表全部</returns>
        ''' <remarks>查詢員工基本資料傳入工號或姓名都可以空白代表全部</remarks>
        Public Function GetUsers(ByVal UIDOrUserName As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetUsers(UIDOrUserName)
        End Function

        ''' <summary>
        ''' 取得使用者姓名
        ''' </summary>
        ''' <param name="UID"></param>
        ''' <returns>取得使用者姓名</returns>
        ''' <remarks>取得使用者姓名</remarks>
        Public Function GetUserName(ByVal UID As String, ByVal dbName As String) As String
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetUserName(UID)
        End Function


        Public Sub SetLanguage(ByVal UID As String, ByVal UICulture As String, ByVal dbName As String)
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            db1.SetLanguage(UID, UICulture, dbName)
        End Sub


        Public Function GetLanguage(ByVal UID As String, ByVal dbName As String) As String
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetLanguage(UID, dbName)
        End Function

        '''' <summary>
        '''' 取得所有部門的資料
        '''' </summary>
        '''' <returns></returns>
        '''' <remarks></remarks>
        'Public Function GetDeptData(ByVal dbName As String) As DataTable
        '    Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
        '    Return db1.GetDeptData()
        'End Function
        '''' <summary>
        '''' 取得所有部門的資料並加入1筆空白
        '''' </summary>
        '''' <returns></returns>
        '''' <remarks></remarks>
        'Public Function GetDeptDataAddBlank(ByVal dbName As String) As DataTable

        '    Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
        '    Return db1.GetDeptDataAddBlank()
        'End Function
        ''' <summary>
        ''' 檢查有代理人設定,true=有代理人
        ''' </summary>
        ''' <param name="emp_id">VIP</param>
        ''' <param name="Agent_emp_id">代理人</param>
        ''' <returns>檢查有代理人設定,true=有代理人</returns>
        ''' <remarks>檢查有代理人設定,true=有代理人</remarks>
        Public Function ChkVIPAgend(ByVal emp_id As String, ByVal Agent_emp_id As String, ByVal dbName As String) As Boolean
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.ChkVIPAgent(emp_id, Agent_emp_id)
        End Function



        ''' <summary>
        ''' 取得代理人,如有個人代理設定以個人為準,若不在個人設定的會找小單位找不到再找大單直到全找完為止
        ''' </summary>
        ''' <param name="emp_id">VIP</param>
        ''' <returns>取得代理人,如有個人代理設定以個人為準,若不在個人設定的會找小單位找不到再找大單直到全找完為止</returns>
        ''' <remarks>取得代理人,如有個人代理設定以個人為準,若不在個人設定的會找小單位找不到再找大單直到全找完為止</remarks>
        Public Function GetVIPAgent(ByVal emp_id As String, ByVal dbName As String) As String

            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbName)
            Return db1.GetVIPAgent(emp_id)
        End Function

        Public Function UserIsQuit(ByVal UID As String, ByVal dbname As String) As Boolean
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbname)
            Return db1.UserIsQuit(UID)
        End Function
        Public Function GetEmpData(ByVal emp_no As String, ByVal dbname As String) As DataTable
            Dim db1 As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO(dbname)
            Return db1.GetEmpData(emp_no)
        End Function
    End Class
End Namespace

